<?

/***************************************************************************
 Jupiter Content System @ Jupiterportal.com
 Copyright (C) 2005 Cosmin Flavius (highstrike@gmail.com)

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.

 More Info About The Licence At http://www.gnu.org/copyleft/gpl.html
****************************************************************************/

//-----------------------------------------------------------------
//  Filter Acces Rightes
//-----------------------------------------------------------------

if(isset($is_guest) || isset($is_user))
{header("location: $PHP_SELF?i=2"); exit; }

//-----------------------------------------------------------------
//  Code for Last 5 online guests
//-----------------------------------------------------------------

$guests = $db->getTable("SELECT ip, browser FROM online WHERE type = 'log' AND status = 'guest' ORDER BY date DESC LIMIT 5");
if(!isset($guestslog)) $guestslog = NULL;

if($guests != FALSE)
{
	foreach($guests as $idx=>$guest)
	{
		//-----------------------------------------------------------------
		//  Make Layout
		//-----------------------------------------------------------------

		$guestslog .= "
			<tr class='".row2color($idx)."' onMouseOver=this.className='con3' onMouseOut=this.className='".row2color($idx)."' onclick=window.open('http://www.dnsstuff.com/tools/whois.ch?ip={$guest['ip']}')>
			<td width='50%'><a href='' title='{$language['Guests online desc']}'>{$guest['ip']}</a></td>
			<td width='50%'>{$guest['browser']}</td>
			</tr>";
	}
}
else
{
	//-----------------------------------------------------------------
	//  Make Layout
	//-----------------------------------------------------------------

	$guestslog .= "
		<tr class='con1'>
		<td colspan='2'>{$language['Guests online desc3']}</td>
		</tr>\n";
}

//-----------------------------------------------------------------
//  Code for Last 5 online members
//-----------------------------------------------------------------

$members = $db->getTable("SELECT o.user_id, o.user, o.user_flag, o.user_location, o.user_authorization, u.id FROM online AS o LEFT JOIN users AS u ON o.user_id=u.id WHERE o.type = 'log' AND o.status = 'member' ORDER BY date DESC LIMIT 5");
if(!isset($memberslog)) $memberslog = NULL;

if($members != FALSE)
{
	foreach($members as $idx=>$member)
	{
		//-----------------------------------------------------------------
		//  See if user exists
		//-----------------------------------------------------------------

		if(isset($member['id']))
		{
			$profile_link = "onclick=window.location.href='$PHP_SELF?n=modules/users&a=1&d={$member['user_id']}'";
			$user_link = "<a href='$PHP_SELF?n=modules/users&a=1&d={$member['user_id']}'>{$member['user']}</a>";
		}
		else
		{
			$profile_link = NULL;
			$user_link = $member['user'];
		}

		//-----------------------------------------------------------------
		//  Make Layout
		//-----------------------------------------------------------------

		$memberslog .= "
			<tr class='".row2color($idx)."' onMouseOver=this.className='con3' onMouseOut=this.className='".row2color($idx)."' $profile_link>
			<td width='1%' align='center'>".find_flag($member['user_flag'],$member['user_location'])."</td>
			<td width='49%'>$user_link</td>
			<td width='50%'>".find_authorization($member['user_authorization'])."</td>
			</tr>";
	}
}
else
{
	//-----------------------------------------------------------------
	//  Make Layout
	//-----------------------------------------------------------------

	$memberslog .= "
		<tr class='con1'>
		<td colspan='3'>{$language['Members online desc2']}</td>
		</tr>\n";
}

//-----------------------------------------------------------------
//  Code for Last 10 loged admin actions
//-----------------------------------------------------------------

$logs = $db->getTable("SELECT user_id, user_user, log, date FROM log ORDER BY id DESC LIMIT 10");
if(!isset($logslog)) $logslog = NULL;

if($logs != FALSE)
{
	foreach($logs as $idx=>$log)
	{
		//-----------------------------------------------------------------
		//  Check if log user is auto protection
		//-----------------------------------------------------------------

		if($log['user_user'] == "Auto Protection")
		{
			$log_user_user = $log['user_user'];
			$log_onclick = NULL;
		}
		else
		{
			$log_user_user = "<a href='$PHP_SELF?n=modules/users&a=1&d={$log['user_id']}'>{$log['user_user']}</a>";
			$log_onclick = "onclick=window.location.href='$PHP_SELF?n=modules/users&a=1&d={$log['user_id']}'";
		}

		//-----------------------------------------------------------------
		//  Make Layout
		//-----------------------------------------------------------------

		$logslog .= "
			<tr class='".row2color($idx)."' onMouseOver=this.className='con3' onMouseOut=this.className='".row2color($idx)."' $log_onclick>
			<td width='15%' align='center'>".today_yesterday($log['date'])."</td>
			<td width='15%'>$log_user_user</td>
			<td width='70%'>{$log['log']}</td>
			</tr>";
	}
}
else
{
	//-----------------------------------------------------------------
	//  Make Layout
	//-----------------------------------------------------------------

	$logslog .= "
		<tr class='con1'>
		<td colspan='3'>{$language['Admin log desc4']}</td>
		</tr>\n";
}

//-----------------------------------------------------------------
//  Start Display
//-----------------------------------------------------------------

?>
<table class="main" cellspacing="1" cellpadding="4">
<tr class='con1'><td><?= $language['Admin name'] ?></td></tr>
</table>
<table><tr><td></td></tr></table>

<table class="main" cellspacing="1" cellpadding="4">
<col width="50%"><col width="50%">
<tr class="head"><td colspan="2"><?= $language['Admin site title'] ?></td></tr>
<tr class="bottom"><td colspan="2"><?= $language['Admin site title2'] ?></td></tr>
<? if(isset($is_webmaster)) { ?>
<tr class="con1">
<td onMouseOver=this.className='con3' onMouseOut=this.className='con1' onclick=window.location.href="<?= $PHP_SELF ?>?n=modules/system"><a href="<?= $PHP_SELF ?>?n=modules/system"><img src="../images/icons_admin/Site_Management.png" border="0" align="top"> &nbsp; <font size=2><?= $language['Admin site desc'] ?></font></a></td>
<td onMouseOver=this.className='con3' onMouseOut=this.className='con1' onclick=window.location.href="<?= $PHP_SELF ?>?n=modules/admin-actions"><a href="<?= $PHP_SELF ?>?n=modules/admin-actions"> <img src="../images/icons_admin/Logged_Admin_Actions.png" border="0" align="top"> &nbsp; <font size=2><?= $language['Admin site desc2'] ?></font></a></td>
</tr>
<tr class="con1">
<td onMouseOver=this.className='con3' onMouseOut=this.className='con1' onclick=window.location.href="<?= $PHP_SELF ?>?n=modules/blocks"><a href="<?= $PHP_SELF ?>?n=modules/blocks"> <img src="../images/icons_admin/Blocks_Management.png" border="0" align="top"> &nbsp; <font size=2> <?= $language['Admin site desc3'] ?></font></a></td>
<td onMouseOver=this.className='con3' onMouseOut=this.className='con1' onclick=window.location.href="<?= $PHP_SELF ?>?n=modules/layout"><a href="<?= $PHP_SELF ?>?n=modules/layout">  <img src="../images/icons_admin/Layout_Management.png" border="0" align="top"> &nbsp; <font size=2> <?= $language['Admin site desc4'] ?></font></a></td>
</tr>
<? } if(isset($is_webmaster) || isset($is_administrator)) { ?>
<tr class="con1">
<td onMouseOver=this.className='con3' onMouseOut=this.className='con1' onclick=window.location.href="<?= $PHP_SELF ?>?n=modules/mass-email"><a href="<?= $PHP_SELF ?>?n=modules/mass-email"> <img src="../images/icons_admin/Mass_Email_Management.png" border="0" align="top"> &nbsp; <font size=2> <?= $language['Admin site desc5'] ?></font></a></td>
<td onMouseOver=this.className='con3' onMouseOut=this.className='con1' onclick=window.location.href="<?= $PHP_SELF ?>?n=modules/pm&a=4&u=1"><a href="<?= $PHP_SELF ?>?n=modules/pm&a=4&u=1"> <img src="../images/icons_admin/Mass_PM_Management.png" border="0" align="top"> &nbsp; <font size=2> <?= $language['Admin site desc19'] ?></font></a></td>
</tr>
<tr class="con1">
<td onMouseOver=this.className='con3' onMouseOut=this.className='con1' onclick=window.location.href="<?= $PHP_SELF ?>?n=modules/ban"><a href="<?= $PHP_SELF ?>?n=modules/ban"> <img src="../images/icons_admin/Bans_Management.png" border="0" align="top"> &nbsp; <font size=2> <?= $language['Admin site desc6'] ?></font></a></td>
<td onMouseOver=this.className='con3' onMouseOut=this.className='con1' onclick=window.location.href="<?= $PHP_SELF ?>?n=modules/adduser"><a href="<?= $PHP_SELF ?>?n=modules/adduser"> <img src="../images/icons_admin/Users_Management.png" border="0" align="top"> &nbsp; <font size=2> <?= $language['Admin site desc20'] ?></font></a></td>
</tr>
<tr class="con1">
<td onMouseOver=this.className='con3' onMouseOut=this.className='con1' onclick=window.location.href="<?= $PHP_SELF ?>?n=modules/main-nav"><a href="<?= $PHP_SELF ?>?n=modules/main-nav"> <img src="../images/icons_admin/Main_Nav_Management.png" border="0" align="top"> &nbsp; <font size=2> <?= $language['Admin site desc7'] ?></font></a></td>
<td onMouseOver=this.className='con3' onMouseOut=this.className='con1' onclick=window.location.href="<?= $PHP_SELF ?>?n=modules/poll"><a href="<?= $PHP_SELF ?>?n=modules/poll"> <img src="../images/icons_admin/Poll_Management.png" border="0" align="top"> &nbsp; <font size=2> <?= $language['Admin site desc8'] ?></font></a></td>
</tr>
<? } ?>
<tr class="con1">
<td onMouseOver=this.className='con3' onMouseOut=this.className='con1' onclick=window.location.href="<?= $PHP_SELF ?>?n=modules/emoticons"><a href="<?= $PHP_SELF ?>?n=modules/emoticons"> <img src="../images/icons_admin/Emoticons_Management.png" border="0" align="top"> &nbsp; <font size=2> <?= $language['Admin site desc9'] ?></font></a></td>
<td onMouseOver=this.className='con3' onMouseOut=this.className='con1' onclick=window.location.href="<?= $PHP_SELF ?>?n=modules/badwords"><a href="<?= $PHP_SELF ?>?n=modules/badwords"> <img src="../images/icons_admin/Bad_Words_Management.png" border="0" align="top"> &nbsp; <font size=2> <?= $language['Admin site desc10'] ?></font></a></td>
</tr>
<tr class="con1">
<td onMouseOver=this.className='con3' onMouseOut=this.className='con1' onclick=window.location.href="<?= $PHP_SELF ?>?n=modules/online&a=4"><a href="<?= $PHP_SELF ?>?n=modules/online&a=4"> <img src="../images/icons_admin/Logged_Members.png" border="0" align="top"> &nbsp; <font size=2> <?= $language['Admin site desc11'] ?></font></a></td>
<td onMouseOver=this.className='con3' onMouseOut=this.className='con1' onclick=window.location.href="<?= $PHP_SELF ?>?n=modules/online&a=3"><a href="<?= $PHP_SELF ?>?n=modules/online&a=3"> <img src="../images/icons_admin/Logged_Guests.png" border="0" align="top"> &nbsp; <font size=2> <?= $language['Admin site desc12'] ?></font></a></td>
</tr>
<tr class="con1">
<td onMouseOver=this.className='con3' onMouseOut=this.className='con1' onclick=window.location.href="<?= $PHP_SELF ?>?n=modules/partners&a=1"><a href="<?= $PHP_SELF ?>?n=modules/partners&a=1"> <img src="../images/icons_admin/Partners_Management.png" border="0" align="top"> &nbsp; <font size=2> <?= $language['Admin site desc21'] ?></font></a></td>
<td onMouseOver=this.className='con3' onMouseOut=this.className='con1' onclick=window.location.href="<?= $PHP_SELF ?>?n=modules/status"><a href="<?= $PHP_SELF ?>?n=modules/status"> <img src="../images/icons_admin/Host_Status_Check.png" border="0" align="top"> &nbsp; <font size=2> <?= $language['Admin site desc22'] ?></font></a></td>
</tr>
<? if(isset($is_webmaster) || isset($is_administrator)) { ?>
<tr class="bottom"><td colspan="2"><?= $language['Admin site title3'] ?></td></tr>
<tr class="con1">
<td onMouseOver=this.className='con3' onMouseOut=this.className='con1' onclick=window.location.href="<?= $PHP_SELF ?>?n=modules/forum-admin&a=1"><a href="<?= $PHP_SELF ?>?n=modules/forum-admin&a=1"> <img src="../images/icons_admin/Categories_Management.png" border="0" align="top"> &nbsp; <font size=2> <?= $language['Admin site desc15'] ?></font></a></td>
<td onMouseOver=this.className='con3' onMouseOut=this.className='con1' onclick=window.location.href="<?= $PHP_SELF ?>?n=modules/forum-admin&a=2"><a href="<?= $PHP_SELF ?>?n=modules/forum-admin&a=2"> <img src="../images/icons_admin/Subcategories_Management.png" border="0" align="top"> &nbsp; <font size=2> <?= $language['Admin site desc16'] ?></font></a></td>
</tr>
<tr class="con1">
<td onMouseOver=this.className='con3' onMouseOut=this.className='con1' onclick=window.location.href="<?= $PHP_SELF ?>?n=modules/forum-admin&a=3"><a href="<?= $PHP_SELF ?>?n=modules/forum-admin&a=3"> <img src="../images/icons_admin/Prune_Management.png" border="0" align="top"> &nbsp; <font size=2> <?= $language['Admin site desc17'] ?></font></a></td>
<td onMouseOver=this.className='con3' onMouseOut=this.className='con1' onclick=window.location.href="<?= $PHP_SELF ?>?n=modules/forum-admin&a=4"><a href="<?= $PHP_SELF ?>?n=modules/forum-admin&a=4"> <img src="../images/icons_admin/Ranks_Management.png" border="0" align="top"> &nbsp; <font size=2> <?= $language['Admin site desc18'] ?></font></a></td>
</tr>
<? } ?>
</table>
<table><tr><td></td></tr></table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<col width="49%"><col width="2%"><col width="49%">
<tr valign="top">
<td><table class="main" cellspacing="1" cellpadding="4"><tr class="head"><td colspan="2"><?= $language['Admin last title'] ?></td></tr><tr class="bottom"><td><?= $language['Admin last desc'] ?></td><td><?= $language['Admin last desc2'] ?></td></tr><?= $guestslog ?></table></td>
<td>&nbsp;</td>
<td><table class="main" cellspacing="1" cellpadding="4"><tr class="head"><td colspan="3"><?= $language['Admin last title2'] ?></td></tr><tr class="bottom"><td><?= $language['Admin last desc3'] ?></td><td><?= $language['Admin last desc4'] ?></td><td><?= $language['Admin last desc5'] ?></td></tr><?= $memberslog ?></table></td>
</tr>
</table>
<? if(isset($is_webmaster)) { ?>
<table><tr><td></td></tr></table>
<table class="main" border="0" cellspacing="1" cellpadding="4">
<tr class="head"><td colspan="3"><?= $language['Admin log title'] ?></td></tr>
<tr class="bottom"><td><?= $language['Admin log desc'] ?></td><td><?= $language['Admin log desc2'] ?></td><td><?= $language['Admin log desc3'] ?></td></tr>
<?= $logslog ?>
</table>
<? } ?>